<app-withdrawals-list-head [isBatchDeal]=isBatchDeal [withDrewStatus]="withDrewStatus"
                           (event)="withDrawalsSearch($event)" ></app-withdrawals-list-head>

<nz-spin [nzSpinning]="isSpinning">
  <div [ngClass]="isMobile?'wrap-mobile':'wrap'">

    <div style="white-space:nowrap;">
      <button nz-button nzType="primary" (click)="addWithdrawals()">申请提现</button>
      <span *ngIf="roleId == roleIdEnum.SUPER_ADMINISTRATOR">
        <nz-radio-group style="margin-right: 40px" [(ngModel)]="status" (ngModelChange)="changeRadio()">
          <label nz-radio-button nzValue="0">处理</label>
          <label nz-radio-button nzValue="-2">手动打款</label>
          <label nz-radio-button nzValue="-3">拒绝</label>
          <label nz-radio-button nzValue="-4">代付打款</label>
        </nz-radio-group>

        <button nz-button nzType="default" (click)="batchDeal()">批量处理</button>

        <button nz-button nzType="dashed" nzDanger (click)="batchDealRefuse(tplContent)">批量拒绝</button>

        <button nz-button nzType="dashed" nzDanger (click)="sendCode()" [nzLoading]="isLoading">发送验证码</button>
        <input type="text" [(ngModel)]="smsCode" [ngModelOptions]="{standalone: true}"  style="width: 150px" nz-input placeholder="请输入验证码"/>
        <button nz-button nzType="primary" (click)="batchDealMoney()">批量代付</button>
      </span>

      <span>
      <button  nz-button nzType="dashed" style="margin-right: 5px"  (click)="showInvoice()"><i nz-icon nzType="copy" nzTheme="outline"></i>
        <span *ngIf="!isMobile">平台发票信息</span>
      </button>
      </span>
    </div>


    <!--<div class="statis " nz-col nzXs="24" nzSm="24" nzMd="12" nzLg="8" nzXl="6"
         *ngIf="roleId == roleIdEnum.SUPER_ADMINISTRATOR">
        <span class="item">
          已处理总金额：<span class="text-red">{{moneyDispose  | emptyCheckPipe:2}}</span>
        </span>
      <span class="item">
          待处理总金额： <span class="text-red">{{moneyPending | emptyCheckPipe:2 }}</span>
        </span>
    </div>-->
    <ng-template #totalTemplate let-total>

      <ng-container>
        <div class="statis_1 " nz-col nzXs="24" nzSm="24" nzMd="12" nzLg="8" nzXl="6"
             *ngIf="roleId == roleIdEnum.SUPER_ADMINISTRATOR">
        <span class="item">
          已处理总金额：<span class="text-red">{{moneyDispose  | emptyCheckPipe:2}}</span>
        </span>
          <span class="item">
          待处理总金额： <span class="text-red">{{moneyPending | emptyCheckPipe:2 }}</span>
        </span>
        </div>
      </ng-container>
    </ng-template>

    <nz-table #nzTable [nzData]="listOfData" nzTableLayout="fixed" class="statis_table"
              [nzShowTotal]="totalTemplate"
              [(nzPageIndex)]="pageHelper.currentPage" [nzFrontPagination]="false"
              (nzPageIndexChange)="nzPageIndexChange($event)"
              [(nzPageSize)]="pageHelper.pageSize" [nzTotal]="pageHelper.totalItems"
              [nzScroll]="{ x: 'auto' }" [nzPageSizeOptions]="pageHelper.pageSizeOptions" nzShowSizeChanger (nzPageSizeChange)="onPageSizeChange($event)">
      <thead>
      <tr>
        <th *ngIf="roleId == roleIdEnum.SUPER_ADMINISTRATOR">
          <label nz-checkbox (nzCheckedChange)="updateAllChecked(indeterminate)" [(ngModel)]="indeterminate">
          </label>
        </th>
        <th>id</th>
        <th>用户信息</th>
        <th>提现信息</th>
        <th>提现金额</th>
        <th>提现费用</th>
        <th>实际到账</th>
        <th>发票情况</th>
        <th>申请时间 / 处理时间</th>
        <th>状态</th>
        <th>提现类型</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      <ng-container *ngFor="let data of nzTable.data">
        <tr>
          <td nzEllipsis *ngIf="roleId == roleIdEnum.SUPER_ADMINISTRATOR"><label nz-checkbox [nzValue]="data.id"
                                                                                   [(ngModel)]="checkOptions[data.id]"
                                                                                   (nzCheckedChange)="signalCheck($event,data)"></label>
          </td>
          <td nzEllipsis>{{data.id}}</td>
          <td nzEllipsis>
            <a (click)="skipStatistics(data)">
              <ng-container *ngIf="data.roleId !=3">
                <div>{{data.agencyName}}</div>
              </ng-container>
              <div>账号：{{data.userName}}<span style="color: #FF0000"
                                             *ngIf="roleId == roleIdEnum.SUPER_ADMINISTRATOR">({{data.count ? data.count : 0}}
                )</span></div>
              <ng-container>
                <div>负责人: {{data.name}} </div>
              </ng-container>
            </a>
          </td>
          <td nzEllipsis class="text-left">
            <div>银行：{{data.bankName}}</div>
            <div>账户名：{{data.bankCertName}}</div>
            <div>账号：{{data.bankCardNo}}</div>
          </td>
          <td nzEllipsis style="color: #FF0000">¥{{data.money}}</td>
          <td nzEllipsis>
            <div>税点：{{ data.platformTax | emptyCheckPipe:2 | percent:'1.0-3'}}</div>
            <div>税费：{{ data.tax }}</div>
          </td>
          <td nzEllipsis style="color: #55ca55">¥{{ data.actualAccount }}</td>
          <td nzEllipsis>
            <span *ngIf="data.invoiceFlag == 1">代开发票</span>
            <span *ngIf="data.invoiceFlag == 2 " (click)="showAccountInfo(data)" style="color:blue" class="clicks"
            >自开发票</span>
          </td>
          <td nzEllipsis>
            <div>{{ data.createTime | date:"yyyy-MM-dd HH:mm:ss" }}</div>
            <div>{{data.updateTime | date:"yyyy-MM-dd HH:mm:ss"}}</div>
          </td>
          <td nzEllipsis>
            <div>
              <span *ngIf="data.status == 0" style="color: #55ca55">待处理</span>
              <span *ngIf="data.status == 2 && (data.remark==null || data.remark=='')" style="color: #28a745">完成</span>
              <span *ngIf="data.status == 2 && data.remark!=null && data.remark!=''" style="color: #28a745" nz-tooltip
                    [nzTooltipTitle]="contentTemplate">完成</span>
              <span *ngIf="data.status == 3" style="color:#dc3545" nz-tooltip [nzTooltipTitle]="contentTemplate"
                    nzMouseLeaveDelay="1" class="clicks">
           <span> 拒绝 </span>
             <i nz-icon nzType="exclamation-circle" nzTheme="fill"></i>
          </span>
              <span *ngIf="data.status == 4 " style="color: #28a745">代付打款中</span>
              <ng-container *ngIf="roleId == roleIdEnum.SUPER_ADMINISTRATOR">
                <span *ngIf="data.status == 1" style="color: #00abf0">处理中</span>
                <span *ngIf="data.status == 5" style="color: #28a745" nz-tooltip [nzTooltipTitle]="contentTemplate"
                      nzMouseLeaveDelay="1" class="clicks">
                <span> 代付打款失败</span>
                  <i nz-icon nzType="exclamation-circle" nzTheme="fill"></i>
              </span>
              </ng-container>
              <ng-container *ngIf="roleId != roleIdEnum.SUPER_ADMINISTRATOR">
                <span *ngIf="data.status == 1 || data.status == 5" style="color: #00abf0">处理中</span>
              </ng-container>
            </div>
          </td>
          <ng-template #contentTemplate>
            <span *ngIf="data.status == 3">{{data.failReason}}</span>
            <span *ngIf="data.status == 5">{{data.remark}}</span>
            <span *ngIf="data.status == 2">{{data.remark}}</span>
          </ng-template>
          <td nzEllipsis>
            <ng-container *ngIf="data?.autoSettlement == 1">
              <span class="color-red">自动结算</span>
            </ng-container>
            <ng-container *ngIf="data?.autoSettlement != 1">
              <span *ngIf="data?.withdrawType == 1">余额提现</span>
              <span *ngIf="data?.withdrawType == 2">分润提现</span>
            </ng-container>
          </td>
          <td nzEllipsis>
            <div *ngIf="roleId == roleIdEnum.SUPER_ADMINISTRATOR">
              <span *ngIf="data.status == 0">
                <button [nzSize]="'small'" nz-button nzType="primary"
                        (click)="disposeMoney(data)">处理
                </button>
              </span>
              <span *ngIf="data.status == 1 || data.status == 5">
                <button [nzSize]="'small'" nz-button nzType="primary"
                        (click)="manualMoneyRemit(data,manualMoney)">手动打款
                </button>
                 <nz-divider nzType="vertical"></nz-divider>
                <button *ngIf="data.invoiceFlag == 1" [nzSize]="'small'" nz-button nzType="primary"
                        (click)="daiFuMoneyRemit(data)">代付打款
                </button>
                 <nz-divider *ngIf="data.invoiceFlag == 1" nzType="vertical"></nz-divider>
                <button [nzSize]="'small'" nz-button nzType="danger"
                        (click)="repulseMoney(data, tplContent)">拒绝
                </button>
              </span>
              <span *ngIf="data.status == 2">打款成功</span>
              <span *ngIf="data.status == 3">拒绝</span>
              <span *ngIf="data.status == 4">代付打款中</span>
            </div>
            <div *ngIf="roleId != roleIdEnum.SUPER_ADMINISTRATOR">
              <span *ngIf="data.status == 0">待处理</span>
              <span *ngIf="data.status == 1 || data.status == 5">处理中</span>
              <span *ngIf="data.status == 2">打款成功</span>
              <span *ngIf="data.status == 3">拒绝</span>
              <span *ngIf="data.status == 4">代付打款中</span>
            </div>
          </td>
        </tr>
      </ng-container>
      </tbody>
    </nz-table>
  </div>
</nz-spin>

<ng-template #manualMoney let-params let-ref="modalRef">
  <nz-form-item>
    <nz-form-label [nzSpan]="5">手动打款原因</nz-form-label>
    <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请输入手动打款原因!">
      <input nz-input onkeyup="this.value=this.value.replace(/^ +| +$/g,'')" [(ngModel)]="remark"
             [ngModelOptions]="true" placeholder="手动打款原因"/>
    </nz-form-control>
  </nz-form-item>
</ng-template>


<ng-template #tplContent let-params let-ref="modalRef">
  <nz-form-item>
    <nz-form-label [nzSpan]="5" nzFor="servicePhoneNo">拒绝原因</nz-form-label>
    <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请输入拒绝原因!">
      <input nz-input onkeyup="this.value=this.value.replace(/^ +| +$/g,'')" [(ngModel)]="failReason"
             [ngModelOptions]="true" placeholder="拒绝原因"/>
    </nz-form-control>
  </nz-form-item>
</ng-template>

<app-account-info [isVisible]="accountIsVisible" (emit)="AccountInfo($event)" [moneyWithdraw]="moneyWithdraw"
></app-account-info>
<app-bind-bank-card [isVisible]="isVisible"
                    (emit)="emitBindBankCard($event)"></app-bind-bank-card>
<app-invoice-info [isVisible]="isVisibleInvoice" (emit)="eventInvoice($event)" ></app-invoice-info>

